-----------------------------------------------------------------------------------------------------------------------
json = require('json')


-----------------------------------------------------------------------------------------------------------------------
misptemp_name = 'misptemp'
mispfile_name = 'mispfile'
source_name = 'source.src'
target_name = 'target.trg'


-----------------------------------------------------------------------------------------------------------------------
-- init misp data
misp_data = {}
misp_data['configs'] = {}
configs = misp_data['configs']
misp_data['phases'] = {}
phases = misp_data['phases']

-- add configs
configs['clean_config'] = {}
configs['build_config'] = {}

-- add clean phase
table.insert(configs['clean_config'], 'clean_phase')
table.insert(phases, {
	id = 'clean_phase',
	formulas = {},
	})
formulas = phases[#phases]['formulas']
-- add clean formula
formulas['clean_formula'] = {
		actions = {
			{'-s','del '..target_name},
			{'-s','del '..mispfile_name},
		}
	}

-- add build phase
table.insert(configs['build_config'], 'build_phase')
table.insert(phases, {
	id = 'build_phase',
	formulas = {},
	})
formulas = phases[#phases]['formulas']
-- add build formula
formulas['build_formula'] = {
		sources = { source_name },
		targets = { target_name },
		actions  = {
			{'s','copy /y '..source_name..' '..target_name},
		}
	}

-- write mispfile
ofile = io.open(misptemp_name, 'w')
ofile:write(json.encode(misp_data))
ofile:close()
